Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid an out-of-bounds panic in deflate_stored #255

Conversation

bjorn3
Copy link
Collaborator

@bjorn3 bjorn3 commented Dec 2, 2024

When shifting the window down, it is possible for the end of the window to be after the last initialized byte of the buffer. These uninitialized bytes don't affect the output of the compression, so we can safely skip copying them to avoid the panic. This matches the code a bit higher up which also does a window slide.

Fixes #229

@bjorn3 bjorn3 requested a review from folkertdev December 2, 2024 14:20
@bjorn3 bjorn3 force-pushed the fix_deflate_stored_window_out_of_bounds branch from 895661d to 43ca3df Compare December 2, 2024 14:24
@bjorn3 bjorn3 force-pushed the fix_deflate_stored_window_out_of_bounds branch from 43ca3df to 5e2f935 Compare December 2, 2024 14:26
@folkertdev
Copy link
Collaborator

there is #254 btw

@bjorn3
Copy link
Collaborator Author

bjorn3 commented Dec 2, 2024

Missed that PR. Approved it.

@bjorn3 bjorn3 force-pushed the fix_deflate_stored_window_out_of_bounds branch from 5e2f935 to 4118389 Compare December 2, 2024 14:45
When shifting the window down, it is possible for the end of the window
to be after the last initialized byte of the buffer. These uninitialized
bytes don't affect the output of the compression, so we can safely skip
copying them to avoid the panic. This matches the code a bit higher up
which also does a window slide.
@bjorn3 bjorn3 force-pushed the fix_deflate_stored_window_out_of_bounds branch from 4118389 to 2349467 Compare December 2, 2024 14:49
@folkertdev folkertdev merged commit a699ab7 into trifectatechfoundation:main Dec 2, 2024
20 checks passed
@bjorn3 bjorn3 deleted the fix_deflate_stored_window_out_of_bounds branch December 2, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OOB panic in deflate_stored after deflateParams()
2 participants